package com.rui1024.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rui1024.dao.OrderDao;
import com.rui1024.dao.impl.OrderDaoImpl;
import com.rui1024.util.JDBCUtil;



@WebServlet("/OrderServlet")
public class OrderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public OrderServlet() {
		super();
		// TODO Auto-generated constructor stub
	}


	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {


		JDBCUtil jdbcUtil = new JDBCUtil();
		Connection con=null;

		try {
			con = jdbcUtil.getCon();
			OrderDao od = new OrderDaoImpl();
			int menuId = Integer.parseInt(request.getParameter("menuId"));
			int amount = Integer.parseInt(request.getParameter("amount"));
			od.order(menuId,amount,con);
			System.out.println(menuId+"abc"+amount);

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				jdbcUtil.closeCon(con);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
